home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94c.txt / 000044_swampler@noao.edu _Wed Dec 28 11:41:10 1994.msg < prev    next >
Internet Message Format  |  1995-02-09  |  2KB

  1. Received: from optima.CS.Arizona.EDU by cheltenham.CS.Arizona.EDU; Wed, 28 Dec 1994 11:41:39 MST
  2. Received: from noao.edu by optima.CS.Arizona.EDU (5.65c/15) via SMTP
  3.     id AA22417; Wed, 28 Dec 1994 11:41:38 MST
  4. Received: from orpheus.gemini.edu by noao.edu (4.1/SAG-Noao.G96)
  5.     id AA13719; Wed, 28 Dec 94 11:41:37 MST; for icon-group@cs.arizona.edu
  6. Received: by orpheus.gemini.edu (5.0/SMI-SVR4-SAG03X)
  7.     id AA15285; Wed, 28 Dec 1994 11:41:10 +0700
  8. Date: Wed, 28 Dec 1994 11:41:10 +0700
  9. From: swampler@noao.edu
  10. Message-Id: <9412281841.AA15285@orpheus.gemini.edu>
  11. Subject: Re: Truth-Table generator
  12. To: mslamm@pluto.mscc.huji.ac.il
  13. Cc: icon-group@cs.arizona.edu
  14. Content-Length: 1301
  15.  
  16. You wrote:
  17.  
  18. >>I rather wanted an all generator solution myself. But the problem is that 
  19. >>my truth tables ma have more than two variables (t1 and t2, above). Now 
  20. >>this makes it a bit harder to do it like this...
  21.  
  22. If the number of variables is fixed, you can extend the code (though it
  23. starts getting uglier, fast):
  24.  
  25. procedure main()
  26.  
  27.    every (t1 := (0|1)) & (t2 := (0|1)) & (t3 := (0|1)) do {
  28.       every writes(format( t1 | t2 | t3            # variables
  29.                            "|" |            # separator
  30.                            iand(t1,t2) | ior(t1,t2) |    # functions
  31.                ixor(t1,t2) | iand(t1, ior(t2,t3)) |
  32.                            ior(iand(t1,t2),iand(t1,t3))
  33.                   ))
  34.       write()
  35.       }
  36.  
  37. end
  38.  
  39. There are tricks lying around to generalize to the 'n'th case with generators,
  40. but I've forgotten them!  I was hoping someone would take the solution
  41. I mailed and generalize it... If I remember, the tricks were pretty ugly.
  42. I think I'd just brute force, but maybe change the above formatting slightly
  43. to:
  44.  
  45.    every (t1 := (0|1)) &
  46.          (t2 := (0|1)) &
  47.          (t3 := (0|1))
  48.       do {...
  49.  
  50.  
  51.  
  52. --
  53. Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
  54. --
  55. The Gods that were smiling when you were born are laughing now.
  56.                       -- found in a fortune cookie
  57.